<?php
/* @var $this RosterController */

$this->pageTitle=Yii::app()->name . ' - Roster Control';
$this->breadcrumbs=array(
	'Management'=>array('/site/management/'),
	'Roster Control',
);

Yii::app()->clientScript->registerScript(
   'myHideEffect',
   '$(".flash-success").animate({opacity: 1.0}, 4000).fadeOut("slow");',
   CClientScript::POS_READY
);

/**
$cs = Yii::app()->getClientScript();
$cs->registerCoreScript('jquery');
**/

$this->menu=array(
	array('label'=>'Back to Management', 'url'=>array('/site/management')),
);

?>
<h1>Roster Control</h1>

<?php 

/// FLASH SUCCESS MESSAGE BOX
if(Yii::app()->user->hasFlash('success')):?>
		<center>
    <div class="flash-success" style="width:500px;">
        <center>
		<?php 
		echo Yii::app()->user->getFlash('success');
		echo " ";
		echo CHtml::image(Yii::app()->theme->baseUrl.'/images/checked.png', 
							  '',
							  array(
									'style'=>'width:35px;margin-bottom:-8px;'
								 )
							  );
		?>
		</center>
    </div>
		</center>
	
<?php 
endif; 
?>


<div id='top-wrapper'>

<table>
  <td>
	<div id='leftVisor' style='width:515px;'>
	<!--left Visor-->
	
		<?php $this->renderPartial('_etherpad'); ?>

	</div>
	
  </td>
  <td>
	<div id='calendar' style=''>
	<center>
	<?php
		$now = new DateTime("now");
		$now->setTimeZone(new DateTimeZone("America/Costa_Rica"));
		
		$this->widget('zii.widgets.jui.CJuiDatePicker', array(
			//'model' => $model,
			//'attribute' => 'day_requested',
			'name'=> 'dateSelector',
			'themeUrl' => Yii::app()->baseUrl . '/css/jui',
			'theme' => 'start',
			'cssFile' => 'jquery-ui-1.10.3.custom.css',		
			'value'=>($now->format('W') != $currentWeek)? $monday : $now->format('Y-m-d'),
			'flat'=>true,
			 'options' => array(
								'showOn' => 'both',             // also opens with a button
								'dateFormat' => 'yy-mm-dd',     // format of "2012-12-25"
								'showOtherMonths' => true,      // show dates in other months
								'selectOtherMonths' => true,    // can select dates in other months
								//'changeYear' => true,           // can change year
								//'changeMonth' => true,          // can change month
								'yearRange' => '2013:2020',     // range of year
								//'minDate' => $now->format('Y-m-d'),      // minimum date
								'maxDate' => '2020-12-31',      // maximum date
								'showButtonPanel' => true,      // show button panel
								'onSelect'=> "js: function(dateText,inst){" .
																	   CHtml::ajax(
																			array(
																				'type'=>'GET',
																				'datatype'=>'html',
																				'url'=>Yii::app()->createUrl('roster/ajaxScheduleChange'),
																				'data'=>  array('date'=>'js: $(\'#dateSelector\').val()'),
																				'update'=>'#gridVisor',
																				)
																			)
																		."}",
								),
			'htmlOptions' => array(
				'size' => '10',        
				'maxlength' => '10',  
				'id'=>'dateSelector',
			),
		));				
							
								
	?>
	</center>
	</div>
  </td>
</table>
</div>



<!--gridVISOR -->
<div id="gridVisor">

<?php


$this->renderPartial('_rosterGridView',
					 array(
						'currentWeek'=>$currentWeek,
						'year'=>$year,
					 ),
					 false,
					 false
					); 
?>		
		
</div>

